<% layout('layout/layout') %>
<% block('header').append(`<style>
.head_img {
    border:1px solid #e3e3e3;
    width:67px;
    height:67px;
    display:inline-block;
    border-radius:100%;
    vertical-align:top;
}
.tr_border td + td{
    border-left:1px solid #e3e3e3;
}
.tr_border td {
    border-bottom:1px solid #e3e3e3;
}
.good_sub_img_ul {
  list-style:none;
  padding:5px;
  display:block;
  margin-bottom:0;
}
.good_sub_img_item {
  float:left;
  width:80px;
  border:1px solid #e3e3e3;
  margin-right:5px;
}
.good_sub_img_item img{
max-width:100%;
}
</style>`) %>
<div class="container">
    <ol class="breadcrumb">
        <li><a href="/">首页</a></li>
        <li><a href="/account/index">用户中心</a></li>
        <li class="active"><%= title %></li>
    </ol>
    <div id="accountIndex" class="row">
        <div class="col-md-3 col-xs-3">
            <% include ../navbar/accountLeftNav.ejs %>
        </div>
        <div class="col-md-9 col-xs-9" >
            <div class="section">
                <div class="col-md-6 col-xs-6 padding-top" >
                    <div class="head_img" style="<%=user.headImg?'background:url('+user.headImg+') no-repeat center;background-size:cover;':'' %>"></div>
                    <div style="display:inline-block;padding-left:10px;">
                        <p class="fs18"><%=user.nickname %></p>
                        <p class="text-muted">白石山农场欢迎您的到来</p>
                    </div>
                </div>
                <div class="col-md-6  col-xs-6 " style="border-left:1px dashed #e3e3e3;">
                    <p class="text-muted padding-left">完成个人信息认证购物更方便哦～</p>
                    <ul style="list-style: none">
                        <li><a class="normal_link" href="/account/accountInfo">更新个人资料</a></li>
                        <li><a class="normal_link" href="/account/address">添加收件地址</a></li>
                        <li><a class="normal_link" href="/account/changePwd">修改用户密码</a></li>
                    </ul>
                </div>
            </div>
            <div class="panel panel-default margin-top20">
                <div class="panel-heading fs14">未完成订单</div>
                <div class="panel-body" style="min-height:300px;">
                    <div class="row" style="margin-top:-15px;">
                        <table style="width:100%;">
                            <% orders.forEach(item => { %>
                            <tr class="tr_border text-center">
                                <td style="width: 142px;text-align: center;">订单号：<%=item.orderId %></td>
                                <td style="width:300px;">
                                  <ul class="good_sub_img_ul clearfix">
                                    <% item.goods.forEach(sub => { %>
                                      <li class="good_sub_img_item"><img  src="<%=sub.imgTmb %>" ></li>
                                      <% if (item.goods.length === 1 ) { %>
                                        <li class="good_sub_img_item" style="width: 188px;text-align: left;padding-top: 5px;border: none;"><%=sub.name %></li>
                                      <% }%>
                                    <% }) %>
                                  </ul>
                                </td>
                                <td>￥ <%=item.needPrice %></td>
                                <td style="width:60px;">
                                    <span class="<%=item.statusColor %>"><%=item.statusName %></span>
                                </td>
                                <td class="text-center padding">
                                    <a class="btn btn-primary btn-sm" href="/order/pay/<%=item._id %>" >付款</a>
                                    <p style="margin:0;">
                                        <a href="/account/orderDetail/<%=item._id %>" class="btn btn-link">查看</a>
                                        <a href="/account/orderCancel/<%=item._id %>" class="btn btn-link normal_link btn_cancel">取消</a>
                                    </p>
                                </td>
                            </tr>
                            <%})%>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<% block('footer').append(`<script>
jQuery(function(){
    $('#accountIndex').on('click','.btn_cancel',function(e){
      e.preventDefault()
      var $this = $(this)
      $.confirm('你确定要取消这个订单么','提示',function(res) {
        if(res) {
          $.post($this.attr('href')).done(function(res){
            console.log(res)
            $this.closest('.tr_border').remove()
          })
        }
      })
    })
})

</script>`) %>